× Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 Lesson 6 Lesson 7 Lesson 8 Lesson 9 Lesson 10 Lesson 11 Lesson 12 Lesson 13 Lesson 14 Lesson 15 Lesson 16 Lesson 17 Lesson 18 Lesson 19 Lesson 20 Lesson 21 Lesson 22 Lesson 23 Lesson 24 Lesson 25 Mini Lesson 1 Mini Lesson 2 Mini Lesson 3 Mini Lesson 4 Mini Lesson 5

Lessons

Lesson 19 - If statements

If statements are one of the most fundamental concepts of all programming languages, including Python. The basic premise behind an if statement is, if this statment is true, perform this. However, there is more to an if statement, meet elif and else. Since you can't have more than one If in an if statement, after your first If, you have to use Elif if you still want to perform something if it is true, and you can have as many Elif's as you want. Else is used for when the If and all of the Elif's are false, it will perform what is under the else statement, and there can only be one Else. Here is the basic syntax for an if statement:

if (conditions):

(perform/execute this)

elif (other conditions):

(perform/execute this)

elif (other other conditions):

(perform/execute this)

else:

(perform/execute this)